// import { setting } from "@/config/setting.config";
import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
  RouteRecordRaw,
} from "vue-router";

type RouteRecordRawExt = RouteRecordRaw & { children?: RouteRecordRawExt[] };
// const { isHashRouterMode, isLogin, loginPath, title } = setting;
const title = '嘉会';
const routes: RouteRecordRawExt[] = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    path: "/index",
    name: "index",
    meta: {
      title: "嘉会",
      role: false,
    },
    children: [
      {
        path: "", //path为空默认第一个
        name: "index",
        component: () => import("@/pages/index/index.vue"),
        meta: {
          role: false,
        },
      },
    ],
  },

  {
    path: "/home",
    name: "home",
    meta: {
      title: "嘉会",
      role: false,
    },
    children: [
      {
        path: "", //path为空默认第一个
        name: "home",
        component: () => import("@/pages/home/index.vue"),
        meta: {
          role: false,
        },
      },
    ],
  },
];
const router = createRouter({
  history:createWebHashHistory(),
  // history: true ? createWebHashHistory() : createWebHistory(),
  routes,
});

router.afterEach((to) => {
  // 从to对象中获取meta.title，如果拿不到设为空
  const routerTitle = (to?.meta?.title as string) || title;
  // 如果左边为true就执行右边
  routerTitle && (document.title = routerTitle);
});

export default router;
